/*
 * 
 *  This file is part of Sourceprojects.org Lycia Copyright 2010 noctarius
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */
package org.sourceprojects.lycia.internal.platform.android;

import java.util.List;

import org.sourceprojects.lycia.DefinitionBuilder;
import org.sourceprojects.lycia.ParserContext;
import org.sourceprojects.lycia.QualifiedName;
import org.sourceprojects.lycia.annotations.Attribute;
import org.sourceprojects.lycia.annotations.Base64;
import org.sourceprojects.lycia.annotations.Child;
import org.sourceprojects.lycia.annotations.ContextObject;
import org.sourceprojects.lycia.annotations.Parent;
import org.sourceprojects.lycia.annotations.TextBody;
import org.sourceprojects.lycia.internal.platform.ParameterMatcher;
import org.sourceprojects.lycia.internal.platform.ParameterMatcherFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;

public class AndroidCompatibleParameterMatcherFactoryImpl implements
		ParameterMatcherFactory {

	private static final ParameterMatcher[] PARAMETER_MATCHERS = new ParameterMatcher[] {
			// Child Annotations
			new ParameterMatcher(Element.class, Child.class),
			new ParameterMatcher(List.class, Child.class),
			new ParameterMatcher(String.class, Child.class),
			new ParameterMatcher(QualifiedName.class, Child.class),
			new ParameterMatcher(Object.class, Child.class),

			// Parent Annotations
			new ParameterMatcher(Element.class, Parent.class),
			new ParameterMatcher(String.class, Parent.class),
			new ParameterMatcher(QualifiedName.class, Parent.class),
			new ParameterMatcher(Object.class, Parent.class),

			// Additional Parameter Annotations
			new ParameterMatcher(Object.class, ContextObject.class),
			new ParameterMatcher(byte[].class, Base64.class),
			new ParameterMatcher(String.class, Base64.class),
			new ParameterMatcher(boolean.class, TextBody.class),
			new ParameterMatcher(byte.class, TextBody.class),
			new ParameterMatcher(short.class, TextBody.class),
			new ParameterMatcher(int.class, TextBody.class),
			new ParameterMatcher(long.class, TextBody.class),
			new ParameterMatcher(float.class, TextBody.class),
			new ParameterMatcher(double.class, TextBody.class),
			new ParameterMatcher(Boolean.class, TextBody.class),
			new ParameterMatcher(Byte.class, TextBody.class),
			new ParameterMatcher(Short.class, TextBody.class),
			new ParameterMatcher(Integer.class, TextBody.class),
			new ParameterMatcher(Long.class, TextBody.class),
			new ParameterMatcher(Float.class, TextBody.class),
			new ParameterMatcher(Double.class, TextBody.class),
			new ParameterMatcher(String.class, TextBody.class),
			new ParameterMatcher(byte[].class, TextBody.class),
			new ParameterMatcher(Object.class, TextBody.class),
			new ParameterMatcher(Attr.class, Attribute.class),
			new ParameterMatcher(boolean.class, Attribute.class),
			new ParameterMatcher(byte.class, Attribute.class),
			new ParameterMatcher(short.class, Attribute.class),
			new ParameterMatcher(int.class, Attribute.class),
			new ParameterMatcher(long.class, Attribute.class),
			new ParameterMatcher(float.class, Attribute.class),
			new ParameterMatcher(double.class, Attribute.class),
			new ParameterMatcher(Boolean.class, Attribute.class),
			new ParameterMatcher(Byte.class, Attribute.class),
			new ParameterMatcher(Short.class, Attribute.class),
			new ParameterMatcher(Integer.class, Attribute.class),
			new ParameterMatcher(Long.class, Attribute.class),
			new ParameterMatcher(Float.class, Attribute.class),
			new ParameterMatcher(Double.class, Attribute.class),
			new ParameterMatcher(String.class, Attribute.class),
			new ParameterMatcher(Object.class, Attribute.class),

			// Base Parameters without Annotations (this is the event element
			// itself or it's Lycia parameters)
			new ParameterMatcher(Element.class),
			new ParameterMatcher(String.class),
			new ParameterMatcher(QualifiedName.class),
			new ParameterMatcher(ParserContext.class),
			new ParameterMatcher(DefinitionBuilder.class) };

	@Override
	public ParameterMatcher[] provideParameterMatchers() {
		final ParameterMatcher[] temp = new ParameterMatcher[PARAMETER_MATCHERS.length];
		System.arraycopy(PARAMETER_MATCHERS, 0, temp, 0,
				PARAMETER_MATCHERS.length);

		return temp;
	}

}
